home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 760 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  46 lines

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: roberino@aol.com (Roberino)
  3. Newsgroups: comp.lang.c
  4. Subject: HELP! File Pointers
  5. Date: 8 Jan 1996 23:32:12 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4csr4c$fem@newsbf02.news.aol.com>
  9. Reply-To: roberino@aol.com (Roberino)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12. I am currently trying to keep one file open while opening other
  13. files one at a time using a separate file pointer.  However, as
  14. soon as I read a line from the second file, the first file pointer
  15. somehow gets destroyed and set to some position in the newly
  16. opened file.  Has anyone else encountered this?  And if so,
  17. is there a solution? (i.e. A way to protect the first file pointer
  18. from being overwritten.)
  19.  
  20. Here are the steps I am performing:
  21.  
  22. void main()
  23. {
  24.     FILE *File1;
  25.     FILE *File2;
  26.  
  27.     File1 =   fopen("FILENAME", "r+");
  28.     
  29.     /* loop through lines in File1 using fgets() */
  30.  
  31.     if (Condition) /* just indicating some condition was met */
  32.     {
  33.         File2 = fopen("FILENAME2", "r+");
  34.       
  35.         fgets(Line, File2); <----- As soon as this occurs, File1 gets
  36.                                           wiped out.  Why?
  37.     }
  38. }
  39.  
  40. Please send any and all replies through email to
  41.                 roberino@aol.com.
  42. I appreciate any and all help.
  43.  
  44. Thank you,
  45. Rob
  46.